package com.jzqf.wheelview;

import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.RecyclerView;

import com.jzqf.wheel.CircleListView;
import com.jzqf.wheel.WheelView;

public class WheelActivity extends AppCompatActivity {

    private TextView mResultTv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        int option = getWindow().getDecorView().getSystemUiVisibility();
        getWindow().getDecorView().setSystemUiVisibility(option | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
        getWindow().setStatusBarColor(Color.TRANSPARENT);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_wheel);
        findViewById(R.id.wheel_back_iv).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        WheelView wheelView = findViewById(R.id.wheel_wheelView);
        CircleListView circleListView = findViewById(R.id.wheel_circleListView);
        mResultTv = findViewById(R.id.wheel_result_tv);
        wheelView.setData(Data.getList(this));
        wheelView.setOnWheelItemClickListener(new WheelView.OnWheelItemClickListener() {
            @Override
            public void onWheelItemClick(WheelView parent, int position) {
                mResultTv.setText(parent.getDatas().get(position).getDesc());
            }
        });
        wheelView.setOnAngleSelectListener(new WheelView.OnWheelAngleSelectListener() {
            @Override
            public void onWheelAngleSelect(WheelView parent, int position) {
                mResultTv.setText(parent.getDatas().get(position).getDesc());
            }
        });
        RecyclerView recyclerView;
        findViewById(R.id.start_btn).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(getBaseContext(), CircleLayoutActivity.class));
            }
        });
        circleListView.setDatas(Data.getList(this));
        circleListView.setOnWheelItemClickListener(new CircleListView.OnItemClickListener() {
            @Override
            public void onItemClick(CircleListView parent, int position) {
                Toast.makeText(getBaseContext(), parent.getDatas().get(position).getDesc(), Toast.LENGTH_SHORT).show();
            }
        });
    }


}
